// pages/setting/setting.js
const app = getApp()
let audioAction1=app.globalData.audioAction
let Button=app.globalData.audioButton
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current: {
      src: 'http://m10.music.126.net/20201209163035/ab101fa06024c173a40dbe889376a6b4/ymusic/51e3/0ce7/8e50/a43d5cc70d2d7d638f7f10d54841c3c0.mp3',
    },
    audioAction: {
      method: 'play'
    },
    audioButton: {
      method: 'play'
    },
    switchChecked1: true,
    switchChecked2: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad:function(){
    if(audioAction1.method=='play'){
      this.setData({
        audioAction: {
          method: 'play'
        },
        switchChecked1: true
      });
    }else {
      this.setData({
        audioAction: {
          method: 'pause'
        },
        switchChecked1: false
      });
    }
    if(Button.method=='play'){
      this.setData({
        audioButton: {
          method: 'play'
        },
        switchChecked2: true
      });
    }else {
      this.setData({
        audioButton: {
          method: 'pause'
        },
        switchChecked2: false
      });
    }
  },
  switchChange1() {
    if(audioAction1.method=='play')
    {
      this.setData({
        audioAction: {
          method: 'pause'
        }
      });
      audioAction1.method='pause';
    } 
    else
    {
      this.setData({
        audioAction: {
          method: 'play'
        }
      });
      audioAction1.method='play';
    }
  },
  switchChange2() {
    if(Button.method=='play')
    {
      this.setData({
        audioButton: {
          method: 'pause'
        }
      });
      Button.method='pause';
    } 
    else
    {
      this.setData({
        audioButton: {
          method: 'play'
        }
      });
      Button.method='play';
    }
  }
})